#ifndef INPUT_HPP
#define INPUT_HPP

#include <iostream>
#include <vector>
#include <typeinfo>

#include "../src/scene.hpp"
#include "../src/raytracer.hpp"
#include "../src/grid.hpp"
#include "../src/light.hpp"
#include "../src/object.hpp"
#include "../src/sphere.hpp"
#include "../src/plane.hpp"
#include "../src/material.hpp"
#include "../src/scene.hpp"
#include "../src/plane.hpp"
#include "../src/color.hpp"
#include "../src/vector.hpp"

#include <QListWidget>
#include <QtGui>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QString>
#include <QFile>

using namespace std;

class Input : public QXmlStreamReader, public QXmlStreamWriter {

	Q_DECLARE_TR_FUNCTIONS(Input);
	
public:
	Input(char*);
	Input(QString);
	~Input(void);

	void parse(void);
	void save(void);
		
	Scene* get_scene(void) const;
	Raytracer* get_raytracer(void) const;
	Grid* get_grid(void) const;
	QListWidget* get_list_widget(void) const;

private:
	Vector parse_vector(void);
	void write_vector(const Vector&);

	Color parse_color(void);
	void write_color(const Color&);

	Material* parse_material(void);
	void write_material(Object*);
	
	vector<Object*>* parse_objectlist(void);
	void write_objectlist(void);
	Sphere* parse_sphere(void);
	void write_sphere(Sphere*);
	Plane* parse_plane(void);
	void write_plane(Plane*);
	
	vector<Light*>* parse_lightlist(void);
	void wirte_lightlist(void);
	Light* parse_light(void);
	void write_light(void);
	
	Grid* parse_grid(void);
	void write_grid(void);
	Scene* parse_scene(void);
	void write_scene(void);
	Raytracer* parse_raytracer(void);
	void write_raytracer(void);

	QListWidget* list_widget;
	QString file;
	Scene* scene;
	Raytracer* raytracer;
	Grid* grid;
};

#endif
